package com.qf.taobei.controller;

import com.qf.taobei.entity.RespBean;
import com.qf.taobei.entity.Type;
import com.qf.taobei.service.ProductTypeService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/pro")
@Api(tags = "商品类别模块")
public class ProductTypeController {
    @Autowired
    private ProductTypeService productTypeService;

    /**
     * 添加商品类别
     *
     * @param type
     * @return
     */
    @PutMapping("/addProductType")
    @ApiOperation("添加商品类别")
    public RespBean addProductType(Type type) {
        RespBean respBean = productTypeService.addProductType(type);
        return respBean;
    }

    /**
     * 删除商品类别
     *
     * @param id
     * @return
     */
    @PostMapping("/delProductType")
    @ApiOperation("删除商品类别")
    public RespBean delProductType(Integer id) {
        RespBean respBean = productTypeService.delProductType(id);
        return respBean;
    }

    /**
     * 根据ID修改商品类别
     *
     * @param id
     * @return
     */
    @PutMapping("/updateProductTypeById")
    @ApiOperation("修改商品类别")
    public RespBean updateProductTypeById(Integer id) {
        RespBean respBean = productTypeService.updateProductTypeById(id);
        return respBean;
    }

    /**
     * 查询所有商品类别
     *
     * @return
     */
    @GetMapping("/queryAllProductType")
    @ApiOperation("查询所有商品类别")
    public RespBean queryAllProductType() {
        RespBean respBean = productTypeService.queryAllProductType();
        return respBean;
    }

}
